package com.model.model01.demo03;

import com.model.model01.demo03.utils.Operate;
import com.model.model01.demo03.utils.factory.OperateFactory;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try{
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入第一个数字: ");
            String number1 = sc.next();

            System.out.println("请输入运算符: ");
            String operate = sc.next();

            System.out.println("请输入第二个数字: ");
            String number2 = sc.next();

            Operate oper = OperateFactory.createOperate(operate);
            oper.setNumber1(Double.parseDouble(number1));
            oper.setNumber2(Double.parseDouble(number2));
            double result = oper.getResult();

            System.out.println("运算结果：" + result);
        } catch (Exception e) {
            System.out.println("程序异常：" + e);
        }
    }
}
